/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apus.action;

import apus.entity.Account;
import apus.persistence.AccountDAO;
import apus.services.ServiceLocator;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author 21vek
 */
public class CashierAccSearchAction implements Action{

    @Override
    public String getName() {
        return "cashier.account.search";
    }

    @Override
    public ActionResult execute(HttpServletRequest request, HttpServletResponse response) {
        List<Account> accountList = new ArrayList<Account>();
        AccountDAO accountDAO = ServiceLocator.getService(AccountDAO.class);
        if (request.getParameter("sub_id") != null) {
            accountList = accountDAO.readBySubscriber(Integer.parseInt(request.getParameter("sub_id")));
        }
        request.setAttribute("accountList", accountList);
        return ActionResult.forward("/WEB-INF/View/search/cashierAccSearch.jsp");
    }
    
}
